$OpenBSD: patch-agent_mibgroup_tcp-mib_data_access_tcpConn_openbsd_c,v 1.2 2013/12/27 23:08:02 krw Exp $
--- agent/mibgroup/tcp-mib/data_access/tcpConn_openbsd.c.orig	Tue Oct  9 18:28:58 2012
+++ agent/mibgroup/tcp-mib/data_access/tcpConn_openbsd.c	Thu Dec 26 20:03:16 2013
@@ -111,8 +111,8 @@ static int
 _load(netsnmp_container *container, u_int load_flags)
 {
     struct inpcbtable table;
-    struct inpcb   *head, *next, *prev;
-    struct inpcb   inpcb;
+    struct inpcb   *next, *prev;
+    struct inpcb   inpcb, previnpcb;
     struct tcpcb   tcpcb;
     int      StateMap[] = { 1, 2, 3, 4, 5, 8, 6, 10, 9, 7, 11 };
     netsnmp_tcpconn_entry  *entry;
@@ -127,21 +127,29 @@ _load(netsnmp_container *container, u_int load_flags)
 	return -1;
     }
 
-    prev = (struct inpcb *)&CIRCLEQ_FIRST(&table.inpt_queue);
+    next = (struct inpcb *)&TAILQ_FIRST(&table.inpt_queue);
     prev = NULL;
-    head = next = CIRCLEQ_FIRST(&table.inpt_queue);
-
+    
     while (next) {
 	if (!NETSNMP_KLOOKUP(next, (char *)&inpcb, sizeof(inpcb))) {
-	    DEBUGMSGTL(("tcp-mib/data_access/tcpConn", "klookup inpcb failed\n"));
+	    DEBUGMSGTL(("tcp-mib/data_access/tcpConn",
+		"klookup inpcb failed\n"));
 	    break;
 	}
-	if (prev && CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
-	    snmp_log(LOG_ERR,"tcbtable link error\n");
-	    break;
+	if (prev != NULL) {
+		if (!NETSNMP_KLOOKUP(prev, (char *)&previnpcb,
+		    sizeof(previnpcb))) {
+	    		DEBUGMSGTL(("tcp-mib/data_access/tcpConn",
+			    "klookup previnpcb failed\n"));
+			break;
+		}
+		if (TAILQ_NEXT(&previnpcb, inp_queue) != next) {
+		    snmp_log(LOG_ERR,"tcbtable link error\n");
+		    break;
+		}
 	}
 	prev = next;
-	next = CIRCLEQ_NEXT(&inpcb, inp_queue);
+	next = TAILQ_NEXT(&inpcb, inp_queue);
 	if (!NETSNMP_KLOOKUP(inpcb.inp_ppcb, (char *)&tcpcb, sizeof(tcpcb))) {
 	    DEBUGMSGTL(("tcp-mib/data_access/tcpConn", "klookup tcpcb failed\n"));
 	    break;
@@ -153,19 +161,19 @@ _load(netsnmp_container *container, u_int load_flags)
 		if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN) {
 		    DEBUGMSGT(("verbose:access:tcpconn:container",
 			       " skipping listen\n"));
-		    goto skip;
+		    continue;
 		}
 	    }
 	    else if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN) {
 		DEBUGMSGT(("verbose:access:tcpconn:container",
 			    " skipping non-listen\n"));
-		goto skip;
+		continue;
 	    }
 	}
 
 #if !defined(NETSNMP_ENABLE_IPV6)
         if (inpcb.inp_flags & INP_IPV6)
-	    goto skip;
+	    continue;
 #endif
 
         entry = netsnmp_access_tcpconn_entry_create();
@@ -199,9 +207,6 @@ _load(netsnmp_container *container, u_int load_flags)
          */
         entry->arbitrary_index = CONTAINER_SIZE(container) + 1;
         CONTAINER_INSERT(container, entry);
-skip:
-	if (head == next)
-	    break;
     }
 
     if(rc<0)
